import { createSSRApp } from "vue";
import * as Pinia from "pinia";
import App from "./App.vue";
import "@/styles/index.scss";
import "virtual:uno.css";
// import { addRouterIntercept } from "@/utils/routers";
import { dayjsPlugin } from './plugins'
import throttleClick from '@/directives/throttle-click'
import { persistedState } from '@/plugins/persistedState'

export function createApp() {
  const app = createSSRApp(App);
  app.use(dayjsPlugin);
  const pinia = Pinia.createPinia();
  pinia.use(persistedState) // 自定义持久化插件
  app.use(pinia);

  app.config.globalProperties.$uni = uni

  // 注册全局指令
  app.directive('throttle-click', throttleClick)

  // 注册路由拦截器
  // addRouterIntercept()

  return {
    app,
    Pinia
  }
}